package com.yulp.springboot2task.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @description:
 * @date: 2019/11/6 11:23.
 * @author: yulipeng.
 */
public class DateUtil {

    public static final String DATE_FORMAT_LONG = "yyyy-MM-dd HH:mm:ss";
    public static final String DATE_FORMAT_LONG_NUM = "yyyyMMddHHmmss";
    public static final String DF_YYYY_MM_DD = "yyyy-MM-dd";
    public static final String DF_YMD = "yyyyMMdd";

    private static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");

    private static DateTimeFormatter formatterHH = DateTimeFormatter.ofPattern("yyyyMMddHH");

    private static DateTimeFormatter formatterLong = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");

    private static DateTimeFormatter formatterLong2 = DateTimeFormatter.ofPattern(DATE_FORMAT_LONG);

    /**
     * 获取当前日期
     *
     * @return
     */
    public static String currentDate() {
        return LocalDateTime.now().format(formatterLong);
    }

    /**
     * 获取当前日期2
     *
     * @return
     */
    public static String currentDateLong() {
        return LocalDateTime.now().format(formatterLong2);
    }

    /**
     * 获取当前日期3_1
     *
     * @return
     */
    public static String currentDateShort() {
        return LocalDateTime.now().format(formatter);
    }
}
